package org.jftstool.auxiliar;

import org.apache.lucene.document.Document;
import org.apache.lucene.search.ScoreDoc;
import org.apache.lucene.search.TopDocs;
import org.jftstool.JFTSFramework;
import org.jftstool.exceptions.JFTSFrameworkException;
import org.jftstool.searcher.exceptions.JFTSSearcherException;

public class JFTSFrameworkSearchTest2 {

	
	public static void main(String[] args) {
		JFTSFramework jfts = JFTSFramework.getJFTSInstance();
		try {
			jfts.startSession();
	
			
			TopDocs results = jfts.moreLikeThisQuery(3, new String[]{"category"}, null);
			
			System.out.println("total hits: " + results.totalHits);
	        ScoreDoc[] hits = results.scoreDocs;
	        
	        for (ScoreDoc hit : hits) {
	            Document doc = jfts.getDocument(hit.doc);
	            
	            String s = doc.get("id");
            
	            System.out.printf(s + "\n");
	        }
	        
			jfts.closeSession();
		}
		catch (JFTSFrameworkException e) {
			e.printStackTrace();
		}
		catch (JFTSSearcherException e) {
			e.printStackTrace();
		}
	}
}

